export default function(Formkey) {
  return function(target, propertyKey, descriptor) {
    const method = descriptor.value;
    descriptor.value = async function(...args) {
      const that = this._isVue ? this : target;
      if (!that.$refs[Formkey]) throw new ReferenceError('Formkey is not defined or not bind');
      const isValid = await that.$refs[Formkey].validate();
      if (isValid) {
        method.apply(that, args);
      } else {
        console.log('error submit!!');
        return false;
      }
    };
  };
}
